<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      row-key="id"
      :max-height="height"
      border
      stripe
      fit
      highlight-current-row
    >
      <el-table-column prop="processInstanceName" label="标题" min-width="200" align="center"></el-table-column>
      <el-table-column prop="taskName" label="节点" min-width="200" align="center"></el-table-column>
      <el-table-column align="center" label="操作时间" width="150">
        <template slot-scope="scope">
          <span>{{ scope.row.startTime | moment('YYYY-MM-DD HH:mm:ss') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="80" align="center">
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="mini"
            circle
            icon="el-icon-view"
            title="查看"
            @click="handleView(scope.row)"
          ></el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      class="fr"
      v-show="total>0"
      :total="total"
      :page.sync="listQuery.pageNo"
      :limit.sync="listQuery.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import Pagination from '@/views/workflow/components/Pagination'
import { queryStartProcess } from '@/api/workflow/bpmn/runtime'
export default {
  props: ['height'],
  components: {
    Pagination
  },
  data() {
    return {
      total: 0,
      listQuery: {
        pageNo: 1,
        pageSize: 10
      },
      list: [],
      listLoading: false
    }
  },
  computed: {},
  created() {},
  methods: {
    handleFilter() {
      this.total = 0
      this.listQuery.pageNo = 1
      this.getList()
    },
    getList() {
      // 我的发起
      this.listLoading = true
      const params = {
        ...this.listQuery
      }
      queryStartProcess(params).then(response => {
        this.list = response.data.records
        this.total = response.data.total
        this.listLoading = false
      })
    },
    handleView(row) {
      this.$router.push({
        path: '/workflow/bpmn/process',
        query: {
          procdefId: row.processDefinitionId,
          deploymentId: row.deploymentId,
          processInstanceId: row.processInstanceId,
          taskId: row.taskId,
          readonly: 1
        }
      })
    }
  }
}
</script>

<style scoped>
.tree-box {
  height: 200px;
  overflow: auto;
}
</style>
